package datasv.courseProduce_datasv;

import resultmessage.CourseProduceRM;
import data.datafactory.DatabaseOperator;

public class DeleteCoursePublish {

	public static void main(String[] args) {
		System.out.println(new DeleteCoursePublish().deleteCoursePublish("00106130020"));
	}
	public CourseProduceRM deleteCoursePublish(String courseID){
		return deleteInSql(courseID);
	}
	private CourseProduceRM deleteInSql(String courseID){
		String collegeID=courseID.substring(0,3);
		DatabaseOperator op=new DatabaseOperator("college"+collegeID);
		if(!op.ifDatabaseExist()||!op.ifIDExist("course_list", courseID)){
			return CourseProduceRM.COURSEPUBLISH_NOT_EXIT;
		}
		int num=AddCoursePublish.columnNum;
		for (int i = 1; i < num; i++) {
			if(!op.deleteOneInfo("course_list",courseID,AddCoursePublish.columnName[i])){
				return CourseProduceRM.COURSEPUBLISH_NOT_EXIT;
			}
			System.out.println(AddCoursePublish.columnName[i]);
		}
		return CourseProduceRM.SUCCESS;
	}
}

